package com.qf.test;

import com.github.pagehelper.PageHelper;
import com.qf.dao.StudentMapper;
import com.qf.dao.UserMapper;
import com.qf.pojo.Student;
import com.qf.pojo.Teacher;
import com.qf.pojo.User;
import com.qf.util.MyBatisUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/*
 *@Description:
 *@author:刘哥
 *@Date:86180 2022/8/24 17:17
 */
public class Demo {
    private  StudentMapper mapper;
    private UserMapper userMapper;
    @Before
    public void Before(){
        userMapper=MyBatisUtils.getMapper(UserMapper.class);
        mapper= MyBatisUtils.getMapper(StudentMapper.class);
    }
    @After
    public void  After(){
        MyBatisUtils.commit();
        MyBatisUtils.close();
    }
    @Test
    public void testDuiStu(){
        Student student =mapper.selectStu(1001l);
        System.out.println("student = " + student);
    }
    @Test
    public void testDuiTea(){
        Teacher teacher =mapper.selectTea(1l);
        System.out.println("teacher = " + teacher);
    }
    @Test
    public void testTeaOrById(){
        PageHelper.startPage(1,1);
        List<Teacher> teacher =mapper.selectTeaOrById(null);
        System.out.println("teacher = " + teacher);
    }
    @Test
    public void upDateUser(){
        User user = new User();
        user.setUsername("jianwei");
        user.setMoney(10);
        user.setPassword("654321");
        user.setUserId(1);
        userMapper.upDateUser(user);
    }
    @Test
    public void selectIn(){
        List<Long> ids=new ArrayList();
        ids.add(1L);
        ids.add(2L);
        ids.add(3L);

        List<User> userList=userMapper.selectIn(ids);
        System.out.println("userList = " + userList);
    }
    @Test
    public void selectByIdOrName(){
        User user=userMapper.selectByIdOrName(1L,"jianwei");
        System.out.println("user = " + user);
    }
}
